<template>
  <el-menu
    :default-active="'0'"
    :ellipsis="false"
    class="w-full h-full flex"
    mode="horizontal"
    background-color="#545c64"
    text-color="#fff"
    active-text-color="#ffd04b"
    @select="handleSelect"
  >
    <div class="h-full text-white flex items-center px-[20px]">
      <el-icon @click="emit('titleClick')" class="mr-[20px] p-3 border-[1px]">
        <span class="mdi mdi-menu"></span>
      </el-icon>
      <span>Title</span>
    </div>
    <div class="grow"></div>
    <el-menu-item index="3">
      <el-icon><span class="mdi mdi-account"></span></el-icon>
      <span>名字</span>
    </el-menu-item>
    <el-menu-item index="4" disabled>
      <el-icon><span class="mdi mdi-alert-octagram-outline"></span></el-icon>
      <span>禁用</span>
    </el-menu-item>
    <el-sub-menu index="2">
      <template #title>
        <el-icon><span class="mdi mdi-cog"></span></el-icon>
        <span>设置</span>
      </template>
      <el-menu-item index="2-1">item one</el-menu-item>
      <el-menu-item index="2-2">item two</el-menu-item>
      <el-menu-item index="2-3">item three</el-menu-item>
      <el-sub-menu index="2-4">
        <template #title>item four</template>
        <el-menu-item index="2-4-1">item one</el-menu-item>
        <el-menu-item index="2-4-2">item two</el-menu-item>
        <el-menu-item index="2-4-3">item three</el-menu-item>
      </el-sub-menu>
    </el-sub-menu>
  </el-menu>
</template>

<script setup lang="ts">
const emit = defineEmits<{
  (e: 'titleClick'): void;
  (e: 'select', key: string, keyPath: string[]): void;
}>();

const handleSelect = (key: string, keyPath: string[]) => {
  emit('select', key, keyPath);
};
</script>

<style scoped></style>
